using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using TT.Module.sysLogin;
using SfcorpDLL.ety;
using SQLHelper;

namespace SfcorpDLL.dao
{
    public class daoCustomer
    {
        etyBaeSystemParamter basSysParam;

        public daoCustomer(etyBaeSystemParamter ieyBasClassDeclare)
        {
            basSysParam = ieyBasClassDeclare;
        }
        
        public DataTable GetCustomerDtl(etyCustomer inEty)
        {
//            string sql = @"select c.CUSTOMER_ID,c.CUSTOMER_NAM,c.FEE_WAY_ID,c.ENABLE_FLAG,c.REC_NAM,c.REC_TIM,c.SEQ_NO,c.REMARKS,c.COLLABORATE_ID,c.IMP_AMOUNT_SHOW_FLAG,c.EXP_AMOUNT_SHOW_FLAG,c.FRTAGYGROUP_I_E_ID,c.FEE_MOD_COD
//,w.fee_way_nam,r.collaborate_nam,i.i_e_nam,m.fee_mod_nam
//from C_CUSTOMER c
//inner join c_fee_way w on c.fee_way_id=w.fee_way_id
//inner join c_collaborate r on c.collaborate_id=r.collaborate_id
//inner join c_i_e i on c.frtagygroup_i_e_id=i.i_e_id
//inner join c_fee_mod m on c.fee_mod_cod=m.fee_mod_cod
//where rownum<=10 order by seq_no" ;
            string sql = "select * from v_c_customer  order by seq_no ";
            return basSysParam.SqlHelp.ExecuteReader(sql, inEty); 
        }
        public daoResult Insert_Customer(etyCustomer inEty)
        {
            string sql = "insert into C_CUSTOMER(CUSTOMER_ID,CUSTOMER_NAM,FEE_WAY_ID,ENABLE_FLAG,REC_NAM,REC_TIM,SEQ_NO,REMARKS,COLLABORATE_ID,IMP_AMOUNT_SHOW_FLAG,EXP_AMOUNT_SHOW_FLAG,FRTAGYGROUP_I_E_ID,FEE_MOD_COD) values(:CUSTOMER_ID,:CUSTOMER_NAM,:FEE_WAY_ID,:ENABLE_FLAG,:REC_NAM,SYSDATE,nvl(:SEQ_NO,(select nvl(max(SEQ_NO),0)+1 from C_customer)),:REMARKS,:COLLABORATE_ID,1,1,:FRTAGYGROUP_I_E_ID,:FEE_MOD_COD)";
            return basSysParam.SqlHelp.ExecuteTrans(sql, inEty);
        }

       public daoResult Update_Customer(etyCustomer inEty)
        {//IMP_AMOUNT_SHOW_FLAG=:IMP_AMOUNT_SHOW_FLAG,EXP_AMOUNT_SHOW_FLAG=:EXP_AMOUNT_SHOW_FLAG,
            string sql = "update C_CUSTOMER set CUSTOMER_ID=:CUSTOMER_ID,CUSTOMER_NAM=:CUSTOMER_NAM,FEE_WAY_ID=:FEE_WAY_ID,ENABLE_FLAG=:ENABLE_FLAG,UPDATE_NAM=:UPDATE_NAM,UPDATE_TIM=SYSDATE,SEQ_NO=:SEQ_NO,REMARKS=:REMARKS,COLLABORATE_ID=:COLLABORATE_ID,FRTAGYGROUP_I_E_ID=:FRTAGYGROUP_I_E_ID,FEE_MOD_COD=:FEE_MOD_COD,LST_UPD_DATE=SYSDATE where rowid =:ROW_ID ";
            return basSysParam.SqlHelp.ExecuteTrans(sql, inEty);
        }

       public daoResult Delete_Customer(etyCustomer inEty)
        {
            string sql = "delete C_CUSTOMER where ROWID =:ROW_ID " ;
            return basSysParam.SqlHelp.ExecuteTrans(sql, inEty);
        }

    }
}